<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="utf-8">
	<title>学生管理系统</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="description" content="">
	<meta name="author" content="">

	<!-- Bootstrap core CSS -->
	<link href="/admin/bootstrap/css/bootstrap.min.css" rel="stylesheet">

	<!-- Font Awesome -->
	<link href="/admin/css/font-awesome.min.css" rel="stylesheet">

	<!-- ionicons -->
	<link href="/admin/css/ionicons.min.css" rel="stylesheet">

	<!-- Simplify -->
	<link href="/admin/css/simplify.min.css" rel="stylesheet">

</head>

<body class="overflow-hidden light-background">
	<div class="wrapper no-navigation preload">
		<div class="sign-in-wrapper">
			<div class="sign-in-inner">
				<div class="login-brand text-center">
					<i class="fa fa-database m-right-xs"></i> 学生 <strong class="text-skin">管理系统</strong>
				</div>

				<form method="POST" id="regForm">
					<div class="form-group m-bottom-md">
						<input name="email" type="email" class="form-control" placeholder="请输入邮箱">
					</div>
					<div class="form-group">
						<input name="pwd" type="password" class="form-control" placeholder="请输入密码">
					</div>
					<div class="form-group">
						<input name="pwd2" type="password" class="form-control" placeholder="请确认密码">
					</div>
					<div class="form-group">
						<input type="text" class="form-control pull-left" name="code" style="width: 200px;" placeholder="请确认验证码">
						<button type="button" id="sendCode" class="btn btn-success block pull-right">发送验证码</button>
						<div class="clearfix"></div>
					</div>
					<div class="form-group">
						<div class="custom-checkbox">
							<input type="checkbox" id="chkAccept" name="agree">
							<label for="chkAccept"></label>
						</div>
						我同意该协议《<a href="">学生管理协议</a>》
					</div>

					<div class="m-top-md p-top-sm">
						<a href="#" class="btn btn-success block" id='reg'>立即注册</a>
					</div>

					<div class="m-top-md p-top-sm">
						<div class="font-12 text-center m-bottom-xs">我已有账号?</div>
						<a href="/admin/main/login" class="btn btn-default block">登录</a>
					</div>
				</form>
			</div><!-- ./sign-in-inner -->
		</div><!-- ./sign-in-wrapper -->
	</div><!-- /wrapper -->

	<a href="" id="scroll-to-top" class="hidden-print"><i class="icon-chevron-up"></i></a>

	<!-- Le javascript
	    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->

	<!-- Jquery -->
	<script src="/admin/js/jquery-1.11.1.min.js"></script>

	<!-- Bootstrap -->
	<script src="/admin/bootstrap/js/bootstrap.min.js"></script>

	<!-- Slimscroll -->
	<script src='/admin/js/jquery.slimscroll.min.js'></script>

	<!-- Popup Overlay -->
	<script src='/admin/js/jquery.popupoverlay.min.js'></script>

	<!-- Modernizr -->
	<script src='/admin/js/modernizr.min.js'></script>

	<!-- Simplify -->
	<script src="/admin/js/simplify/simplify.js"></script>
	<script src="/admin/js/common.js"></script>
	<script>
		$('#sendCode').on('click',function(){
			var email=$('input[name="email"]').val();
			if(!checkEmail(email)){
					alert('请正确输入邮箱');
					return false;
				}
				$.ajax({
					url: '/admin/main/sendCode',
					type:'post',
					data:{email:email},
					dataType:'json',	// 回调的数据类型
					success:function(res){
						alert(res.msg);
					}
				});
		});
		$('#reg').on('click', function () {
			var formdata = new FormData($('#regForm')[0]);
			if (!checkEmail(formdata.get('email'))) {
				alert('请正确输入邮箱');
				return false;
			}
			if (checkRequired(formdata.get('pwd'))) {
				alert('请输入密码');
				return false;
			}
			if (formdata.get('pwd') != formdata.get('pwd2')) {
				alert('密码不一致');
				return false;
			}
			if (formdata.get('agree') == undefined) {
				alert('请勾选同意协议');
				return false;
			}
			$.ajax({
				url: '/admin/main/registerData',
				type: 'post',
				data: formdata,
				contentType: false,
				processData: false,
				dataType: 'json',
				success: function (res) {
					alert(res.msg);
					if (res.error == 0) {
						location.href = '/admin/main/login';
					}

				}
			})
		})

	</script>
</body>

</html>